package com.sll.hosptials.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sll.hosptials.controller.req.AddOrUpdateRoleInfoReq;
import com.sll.hosptials.controller.req.IdReq;
import com.sll.hosptials.controller.req.RoleInfoListReq;
import com.sll.hosptials.controller.req.RoleInfoPageReq;
import com.sll.hosptials.controller.resp.RoleInfoDetailResp;
import com.sll.hosptials.service.RoleInfoService;
import com.sll.hosptials.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "角色信息")
@RequestMapping("/roleInfo/")
@RestController
public class RoleInfoController {

    @Resource
    private RoleInfoService roleInfoService;

    @ApiOperation("新增")
    @PostMapping("/addOrUpdate")
    public Result<Boolean> addOrUpdate(@RequestBody AddOrUpdateRoleInfoReq req){
        return Result.success(roleInfoService.addOrUpdateRoleInfo(req));
    }


    @ApiOperation("角色信息分页")
    @PostMapping("/page")
    public Result<Page<RoleInfoDetailResp>> page(@RequestBody RoleInfoPageReq req){
        return Result.success(roleInfoService.rolePage(req));
    }

    @ApiOperation("获取所有角色信息")
    @PostMapping("/allRoleInfo")
    public Result<List<RoleInfoDetailResp>> getRoleInfoList(@RequestBody RoleInfoListReq req){
        return Result.success(roleInfoService.getRoleInfoList(req));
    }


    @ApiOperation("获取详情")
    @PostMapping("/detail")
    public Result<RoleInfoDetailResp> detail(@RequestBody IdReq req) {
        return Result.success(roleInfoService.detail(req));
    }

    @ApiOperation("删除")
    @PostMapping("/delete")
    public Result<Boolean> delete(@RequestBody IdReq req) {
        return Result.success(roleInfoService.delete(req));
    }

}
